// import Koa from "koa";
// import Router from "koa-router";

// let app = new Koa();
// let router = new Router(); 

// router.get("/",async(ctx,next)=>{
//     ctx.body="zhang"
// })

//  router.post('/login',async(ctx,next)=>{    let data=ctx.require.body || '无数据'
//  })

// app.use(router.routess)

// //监听
// app.listen(8000)

import Koa from "koa";
import Router from "koa-router";
import bodyParser from "koa-bodyparser";


const app = new Koa();
const router = new Router();

app.use(bodyParser())

router.get("/", async (ctx, next) => {
    ctx.body = "zhang";
});
router.get('/news',(ctx,next)=>{
    ctx.body="主页面"
})
router.get('/view',(ctx,next)=>{
    // console.log(ctx.request.query.name);
    // console.log(ctx.request.querystring);

    let name =ctx.request.params.id ||'什么也没有'
    ctx.body='滚'+name
    
    
})

router.post('/login', async (ctx, next) => {
    let data = ctx.request.body || '无数据';
    ctx.body = date;

    
});

app.use(router.routes());

// 监听
app.listen(7000, () => {
    console.log('Server is running on http://localhost:7000');
});

